<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/12/11
 * Time: 14:40
 */
class City extends MY_Api_Controller
{
    function __construct(){
        parent::__construct();
    }

    function gets(){
        $parent_code= $this->input->get('parent_code');
        $parent_code = $parent_code>0?$parent_code:0;
        $this->load->model('City_model');
        $condition = array('parent_code'=>$parent_code);
        $cities = $this->City_model->fetch_array($condition);
        if(!$cities)
            $this->set_response(10004);
        $this->set_response(0,$cities);
    }

    function get(){
        $id = $this->input->get('city_id');
        $this->load->model('City_model');
        $condition = array('id'=>$id);
        $city = $this->City_model->fetch_array($condition);
        if(!$city)
            $this->set_response(10004);
        $this->set_response(0,$city);
    }

    function get_lecturer(){
        $city_code = $this->input->get('city_code');
        $this->load->model('lecturer/Lecturer_model');
        $lecturer = $this->Lecturer_model->get_by_city($city_code);
        if(!$lecturer)
            $this->set_response(10400);
        $this->set_response(0,$lecturer);
    }

    function get_place(){
        $city_code = $this->input->get('city_code');
        $this->load->model('place/Place_model');
        $place = $this->Place_model->get_by_city($city_code);
        if(!$place)
            $this->set_response(10400);
        $this->set_response(0,$place);
    }
}